﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CKFinder;

public partial class Admin_AddDanhmucsanpham : System.Web.UI.Page
{
    DanhmucsanphamController danhmucsanphamController = new DanhmucsanphamController();
    protected void Page_Load(object sender, EventArgs e)
    {

        CKFinder.FileBrowser fb = new FileBrowser();
        fb.BasePath = "../ckfinder/";
        fb.SetupCKEditor(ckeditor);
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Danhmucsanpham dmsp = new Danhmucsanpham();
        dmsp.Name = txtName.Text;
        dmsp.Url = txtUrl.Text;
        dmsp.Description = ckeditor.Text;
        dmsp.Tag = txtTag.Text;
        dmsp.Order = Convert.ToInt32(txtOrder.Text);
        if (ddlStatus.SelectedIndex == 0)
        {
            dmsp.Status = true;
        }
        else
        {
            dmsp.Status = false;
        }
        dmsp.DateStart = DateTime.Now;
        int id = danhmucsanphamController.Insert(dmsp);
        if (id > 0)
        {
            
            Response.Write("<script>alert('Thêm danh mục sản phẩm thành công')</script>");
            Server.Transfer(Request.RawUrl);
        }
        else
        {
            Response.Write("<script>alert('Thêm danh mục sản phẩm gặp lỗi')</script>");
        }
    }
}